﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Entity;

namespace DAO
{
    public class LoginDAO
    {
        BMS_DatabaseEntities context = new BMS_DatabaseEntities();

        UserEntity uEntity = new UserEntity();
        public bool ValidateLogin(string user, string pass)
        {
            var query = from s in context.USER_ACCOUNT where s.USERNAME == user & s.PASSWORD == pass select s;
            if (query.Count() >= 1)
                return true;
            else
                return false;
        }

        public UserEntity LoadUserInfo(string user)
        {
            var query = (from s in context.USER_ACCOUNT
                         where s.USERNAME == user
                         select s).First();


            uEntity.GroupName = query.GROUP_NAME;
            uEntity.Position = query.POSITION;
            uEntity.StaffName = query.STAFF_NAME;

            return uEntity;
        }


    }
}
